<?php

namespace app\backstage\model;

use app\common\model\Common;
use think\Db;
use think\Model;

/**
 * @property mixed nodes 节点中间表
 */
class ManagerRole extends Model
{
    use Common;

    protected $table = 'cms_manager_role';

    public static function getRoleByAlias($alias)
    {
        return Db::table('cms_manager_role')->where('alias', $alias)->findOrFail();
    }

    public function nodes()
    {
        return $this->belongsToMany(PowerNode::class, RoleToNodeAccess::class, 'node_id', 'role_id')->field("id,node_path");
    }
}